<template>
  
  <div>
      添加商品页面
      <hr>
{{ content }}
      <hr>

      <editor-vue 
      :content="content"
      :readOnlys="readOnlys"
      @changeData="hChangeData"
      @uploadImg="hUploadImg"
      />
  </div>
</template>

<script>
import editorVue from "../../components/Editor.vue"
 export default {
    components: {
      editorVue,
    },
    data() {
      return {
        readOnlys: false,
        content: ``,//给后端传 编辑器的内容
      };
    },
    mounted(){
        if(this.$route.query.goodsid){//ajax请求
             console.log("修改");
        }else{
            console.log("添加");
        }

    },
    methods: {
      hChangeData(editDataHtml){
        // 获取最新的html数据
        this.content = editDataHtml
        console.log(this.content)
      },
      hUploadImg(file,insertFn){//ajax请求
        console.log(file)
        // 插入图片，调接口返回图片url,通过插入conteng
        let imgUrl = 'http://124.223.220.96:28019/upload/20230417_11111210.png'
        
        insertFn(imgUrl);//接口请求成功之后*****调用这个函数
  
        // 设置只读
        // this.readOnlys = true;
      },
    },
  };
</script>

<style>

</style>